﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ThermalEquipmentDesign.Model.CasingPipeSprinklers;
using System.Windows;
using System.Windows.Input;
using ThermalEquipmentDesign.Reference_Path;
using ThermalEquipmentDesign.Reference_Path.Evaporator;

namespace ThermalEquipmentDesign.ViewModel
{
    public class CasingPipeSprinklersViewModel : ObservableObject
    {
        // Declare fields for binding
        #region fields for binding
        private CasingPipeSprinklers osprinklers = new CasingPipeSprinklers();
        private CasingPipeSprinklersModel sprinklersmodel;
        private CasingPipeSprinklersResult ocasingpipesprinklersresult = new CasingPipeSprinklersResult();
        private ICommand calculate;
        private String stooltip = "Press F1 for Help";
        #endregion

        // Create properties for binding
        #region properties for binding
        public String sTooltip
        {
            get { return stooltip; }
            set { stooltip = value; }
        }

        public CasingPipeSprinklers oSprinlers
        {
            get
            {
                return osprinklers;
            }
            set
            {
                if (value != osprinklers)
                {
                    osprinklers = value;
                    OnPropertyChanged("oSprinlers");
                }
            }
        }
        public CasingPipeSprinklersModel SprinklersModel
        {
            get
            {
                return sprinklersmodel;
            }
            set
            {
                if (value != sprinklersmodel)
                {
                    sprinklersmodel = value;
                    OnPropertyChanged("SprinklersModel");
                }
            }
        }
        public CasingPipeSprinklersResult oCasingPipeSprinklersResult
        {
            get
            {
                return ocasingpipesprinklersresult;
            }
            set
            {
                if (value != ocasingpipesprinklersresult)
                {
                    ocasingpipesprinklersresult = value;
                    OnPropertyChanged("oCasingPipeSprinklersResult");
                }
            }
        }
        public ICommand Calculate
        {
            get
            {
                if (calculate == null)
                {
                    calculate = new RelayCommand(
                        param => ImplementCalculation()
                    );
                }
                return calculate;
            }
        }
        #endregion

        /// <summary>
        /// Calculate design parameters for Casing Pipe Sprinklers
        /// </summary>
        public void ImplementCalculation()
        {
            CasingPipeSprinklersModel cpsm = new CasingPipeSprinklersModel();
            oCasingPipeSprinklersResult = cpsm.ImplementCalculation(oSprinlers);
        }
        //  Load Reference for the helping 
        public void LoadReference(string sIndex)
        {
            System.Windows.Forms.Help.ShowHelp(null, ReferencePath.ReferenceFile, System.Windows.Forms.HelpNavigator.Index, CasingPipeSprinklersReference.ResourceManager.GetString(sIndex));
        }
    }
}
